﻿
#include <iostream>
#include <iomanip>
#include <time.h>
#include <random>
#include "MyBayer.h"

using namespace std;


void test(int* values, int length) {
	for (int i = 0; i < length; i++)
	{
		values[i] = ALPHA;
	}
}


u8* input;
u8* output;


void cur(int type, int width,int height) {
	clock_t start, finish;
	double totaltime;

	start = clock();
	BayerConverter(input, output, width, height, type, 0);
	finish = clock();
	totaltime = (double)(finish - start);
	cout << "\n此程序的运行时间为" << totaltime << "毫秒！" << endl;
}


int main() {
	

	default_random_engine e; //或者直接在这里改变种子 e(10) 
	uniform_int_distribution<unsigned> u(0, 255); //随机数分布对象 
	e.seed(10); //设置新的种子

	int key;
	long long width = 1000, height = 1000 * 1000, length;
	length = width * height;
	//创建模拟数据
	input = new u8[length];
	output = new u8[length * 2];


	for (long long i = 0; i < length; i++)
	{
		input[i] = u(e);
	}
	cout << sizeof(unsigned long long) << endl;
	cout << "int长度 : " << sizeof(int) << "个字节" <<"    U8 : "<< sizeof(u8) << "个字节" << "  char : "<<sizeof(char) <<" 个字节" <<endl;

	/*cout << "类型 : GRBG_CPU_C" << endl;
	cur(GRBG_CPU_C, width, height);
	cout << "类型 : GRBG_CPU_O" << endl;
	cur(GRBG_CPU_O, width, height);
	cout << "类型 : GRBG_GPU" << endl;
	cur(GRBG_GPU, width, height);*/

	//cout << "类型 : GRBG_GPU_565   " << endl;
	//cur(GRBG_GPU_RGB565, width, height); 
	//cout << "类型 : GRBG_CPU_565   " << endl;
	//cur(GRBG_CPU_RGB565, width, height);

	//for (int i = 0; i < width * height; i++)
	//{
	//	if (i != 0 && i % width == 0) {
	//		cout << endl;
	//	}

	//	int x = i / width;
	//	int y = i % width;

	//	cout << setiosflags(ios::left) << setw(6) << (int)input[getPosition(x, y, width)] << resetiosflags(ios::left)
	//		<< setiosflags(ios::right) << setw(3)
	//		<< "|";
	//}
	//cout << endl << endl;
	//u16* outtest = (u16*)output;

	//u16 red = 0x001f;
	//u16 green = 0x003f;
	//u16 blue = 0x001f;

	//for (int i = 0; i < width * height; i++)
	//{
	//	if (i != 0 && i % width == 0) {
	//		cout << endl;
	//	}

	//	int x = i / width;
	//	int y = i % width;

	//	/*cout << setiosflags(ios::left) << setw(6) << (int)output[getPositionColor(x, y, 0, width)] << setiosflags(ios::left) << setw(6) << (int)output[getPositionColor(x, y, 1, width)] << resetiosflags(ios::left)
	//		<< setiosflags(ios::right) << setw(6) << (int)output[getPositionColor(x, y, 2, width)] << setw(6) << (int)output[getPositionColor(x, y, 3, width)]
	//		<< "|";*/

	//	/*cout << setiosflags(ios::left) << setw(6) << (int)outtest[getPosition(x, y, width)] << setiosflags(ios::right) << setw(6) <<
	//		(int)(outtest[getPosition(x, y, width)] & third)<< "|";*/

	//	cout<< setiosflags(ios::left) << setw(6) << (int)(outtest[getPosition(x, y, width)] & red) << resetiosflags(ios::left)
	//		<< setiosflags(ios::right) << setw(6) << (int)(outtest[getPosition(x, y, width)] >> 5 & green) << setw(6) << 
	//		(int)(outtest[getPosition(x, y, width)] >> 11 & blue)
	//		<< "|";
	//	//cout << setiosflags(ios::left) << setw(6) << (int)(outtest[getPosition(x, y, width)]) << "|";
	//}
	cin >> key;
}